package errmsg

type Error struct {
	Code int `json:"code"`
	Msg string `json:"msg"`
}

//常量错误码
const (
	SUCCESS = 0  //操作成功
	FAIL = 1    //操作失败
	BIND_DATA_FAIL = 2    //gin数据绑定失败
	PARAMS_TYPE_ERROR = 3
	//user error
	ERROR_USER_NOT_EXIST = 1000
	ERROR_USER_USERNAME_HAVED = 1001
	ERROR_USER_VERIFY_WRONG = 1002
	ERROR_USER_TOKEN_ERROR = 1003
	ERROR_USER_TOKEN_EXPIRE = 1004
	ERROR_USER_NO_TOKEN = 1005
	//article error

	//article category error

)

var codeMsg = map[int]string{
	SUCCESS : "ok",
	FAIL : "fail",
	BIND_DATA_FAIL:"数据绑定失败",
	PARAMS_TYPE_ERROR:"参数类型错误",
	ERROR_USER_NOT_EXIST:"用户不存在！",
	ERROR_USER_USERNAME_HAVED:"用户名已存在!",
	ERROR_USER_VERIFY_WRONG:"用户名或密码错误",
	ERROR_USER_TOKEN_ERROR:"token错误",
	ERROR_USER_TOKEN_EXPIRE:"token已过期",
	ERROR_USER_NO_TOKEN:"token未传递",
}

func GetCodeMsg(code int)string{
	return codeMsg[code]
}